package com.yfbao.horizon.sudoku;

import lombok.Data;

import java.util.HashSet;
import java.util.Set;

public class IndexValueDto {
    private int currentValue=0;
    private boolean isInitData=false;
    private Set<Integer> invalidSet =new HashSet<>();
    public void addInvalid(Integer value){
        invalidSet.add(value);
    }

    public boolean isInvalid(Integer value){
        return invalidSet.contains(value);
    }

    public boolean isInitData(){
        return isInitData;
    }

    public void initData(Integer value){
        currentValue= value;
        isInitData=true;
        invalidSet.add(value);
    }

    public void setCurrentValue(Integer value){
        if(invalidSet.contains(value)){
            throw new RuntimeException("该值已经设置过不满足条件,跳过");
        }
        currentValue= value;
        invalidSet.add(value);
    }

    public void clear(){
        invalidSet.clear();
        if(isInitData){
            invalidSet.add(currentValue);
        }else {
            currentValue=0;
        }
    }

    public Integer getCurrentValue(){
        return currentValue;
    }
}
